clear all
use "EVS.dta"


rename S009 cntry
rename S020 Year
rename X003R2 Age
rename X001 Female 

rename X023 Edu
 g University=0  
 replace University=1 if Edu>19
 

g Material1=(E014-1)/2
g Work=(4-A005)/3
g Politics=(4-A004)/3
g Leisure=(4-A003)/3
g Material2= 3-Y002

* ROBUSTNESS: event analysis  
gen date = .
replace date = 2005 if cntry == "AL"
replace date = 2000 if cntry == "AT"
replace date = 2004 if cntry == "BE"
replace date = 2004 if cntry == "HR"
replace date = 2000 if cntry == "CZ"
replace date = 1999 if cntry == "DK"
replace date = 2002 if cntry == "EE"
replace date = 2006 if cntry == "FI"
replace date = 2006 if cntry == "FR"
replace date = 2002 if cntry == "DE"
replace date = 2005 if cntry == "HU"
replace date = 2001 if cntry == "IT"
replace date = 2001 if cntry == "LV"
replace date = 2000 if cntry == "LT"
replace date = 2000 if cntry == "LU"
replace date = 2002 if cntry == "NL"
replace date = 2006 if cntry == "PL"
replace date = 2006 if cntry == "PT"
replace date = 2004 if cntry == "SI"
replace date = 2005 if cntry == "SK"
replace date = 2005 if cntry == "ES"
replace date = 2007 if cntry == "SE"
replace date = 2002 if cntry == "NO"
drop if date ==.

*replace date=date-1999


 
 *keep if University==1
 
 
 
 
 collapse Material1  Material2 Politics Work Leisure Female  date University Edu Age, by(cntry Year)
 
 
 gen region = .
replace region = 1 if inlist(cntry, "AT", "BE", "FR", "DE", "NL", "LU") // Western
replace region = 2 if inlist(cntry, "CZ", "PL", "SK", "HU", "LT", "LV", "EE") // Eastern
replace region = 3 if inlist(cntry, "SE", "FI", "DK", "NO") // Nordic
replace region = 4 if inlist(cntry, "ES", "PT", "IT") // Southern
replace region = 5 if inlist(cntry, "SI", "HR", "AL") // Balkans

tab region, gen(r)

summarize Work, detail
gen Work_high = .
replace Work_high = 1 if Work > r(p50)
replace Work_high = 0 if Work <= r(p50)

summarize Material1, detail
gen Material1_high = .
replace Material1_high = 1 if Material1 > r(p50)
replace Material1_high = 0 if Material1 <= r(p50)

summarize Material2, detail
gen Material2_high = .
replace Material2_high = 1 if Material2 > r(p50)
replace Material2_high = 0 if Material2 <= r(p50)

summarize Politics, detail
gen Politics_high = .
replace Politics_high = 1 if Politics > r(p50)
replace Politics_high = 0 if Politics <= r(p50)
 
summarize Leisure, detail
gen Leisure_high = .
replace Leisure_high = 1 if Leisure > r(p50)
replace Leisure_high = 0 if Leisure <= r(p50)
 
 
*gen early_adopter = date < 2004
*reg early_adopter Work  Female University Age i.region
*reg early_adopter Material  Female University Age i.region
*reg early_adopter Leisure  Female University Age i.region

* Step 1: Run each regression and store results
eststo clear

reg date Material1_high Female University Age i.region
eststo model1
quietly summarize date
estadd scalar ymean = r(mean)

reg date Material2_high Female University Age i.region
eststo model2
quietly summarize date
estadd scalar ymean = r(mean)

reg date Work_high Female University Age i.region
eststo model3
quietly summarize date
estadd scalar ymean = r(mean)

reg date Leisure_high Female University Age i.region
eststo model4
quietly summarize date
estadd scalar ymean = r(mean)

* Step 2: Export LaTeX table
esttab model1 model2 model3 model4 using "T12.tex", ///
    label b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
    keep(Material1_high Material2_high Work_high Leisure_high) ///
    coeflabels(Material1_high "Materialism A" Material2_high "Materialism B" ///
               Work_high "Importance of Work" Leisure_high "Importance of Leisure") ///
    stats(ymean r2 N, labels("Output mean" "\textit{R}$^2$" "N. Obs") fmt(3 3 %9.0fc)) ///
    booktabs noobs nonotes nolz fragment replace ///
    prehead("\begin{table}[htbp]\centering \footnotesize \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}   \caption{\scshape Robustness: exogenous timing in Section 4 (B) \label{tabTimingB}}  \begin{center}   \begin{threeparttable} \begin{tabular}{l  cccc} \toprule") ///
    prefoot("\\[1.5ex] \cmidrule(lr{0.15em}){1-5}") ///
    postfoot("\bottomrule \end{tabular} \begin{tablenotes}[para,flushleft] \footnotesize \textit{Note:} Robust standard errors in parentheses. \\ * \(p<0.10\), ** \(p<0.05\), *** \(p<0.01\). \end{tablenotes} \end{threeparttable} \end{center} \end{table}")

	
 